package com.wlyuan.open.infrastructure.converter;

import com.wlyuan.core.domain.MappingIds;
import com.wlyuan.core.marker.MappingStatus;
import com.wlyuan.open.dao.entity.OpenApiInfoDO;
import com.wlyuan.open.domain.api.OpenApiInfo;
import com.wlyuan.open.domain.api.utils.MappingOpenApiInfo;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author yuanzheng
 */
public class OpenApiInfoConverter {
    @Mapper(uses = {
            MappingIds.class,
            MappingStatus.class,
            MappingOpenApiInfo.class
    })
    public interface Converter {
        OpenApiInfo convert(OpenApiInfoDO source);

        List<OpenApiInfo> convert(List<OpenApiInfoDO> source);

        @InheritInverseConfiguration
        OpenApiInfoDO convert(OpenApiInfo source);
    }

    private static final Converter CONVERTER = Mappers.getMapper(Converter.class);

    public static OpenApiInfoDO convert(OpenApiInfo source) {
        return CONVERTER.convert(source);
    }

    public static OpenApiInfo convert(OpenApiInfoDO source) {
        return CONVERTER.convert(source);
    }

    public static List<OpenApiInfo> convert(List<OpenApiInfoDO> source) {
        return CONVERTER.convert(source);
    }
}
